package cn.iocoder.yudao.module.mp.controller.admin.open;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.mp.controller.admin.open.vo.MpOpenUserBasicResp;
import cn.iocoder.yudao.module.mp.service.open.MpUserBasicService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 公众号回调 ")
@RestController
@RequestMapping("/mp/open/user/basic")
@Validated
@Slf4j
public class MpUserBasicController {

    @Resource
    private MpUserBasicService mpUserBasicService;


    /**
     * 获取用户信息
     */
    @GetMapping(value = "/{code}")
    @PermitAll
    public CommonResult<MpOpenUserBasicResp> getUserBasic(@PathVariable("code") String code) {
        log.info("[getUserBasic][接收到来自微信服务器的Code值({})]", code);

//        MpOpenUserBasicResp res = new MpOpenUserBasicResp();
//        res.setNickname("xx");
//        res.setSex(0);
//        res.setHeadimgurl("https://thirdwx.qlogo.cn/mmopen/vi_32/PiajxSqBRaEJnxOqualiapz78TQq3OHfFJmvTiaic7MaeoOtTQL3ibzQ8mxe1qRzmjCAOawepVhovRSrl4W3D2RCmBh41DN2G62dzxw1tDuXwN9eS76zQ6PzbeQ/132");

        // 获取用户信息
        return success(mpUserBasicService.getUserBasic(code));
    }
}
